/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.huawei.spare.part.replace.views.replace.confirm;

import com.huawei.spare.part.replace.framework.SmartDataBus;
import com.huawei.spare.part.replace.framework.SmartRouter;
import com.huawei.spare.part.replace.models.Project;
import com.huawei.spare.part.replace.models.Replacement;
import com.huawei.spare.part.replace.views.prepare.project.ProjectBasePresenter;
import io.reactivex.rxjavafx.observables.JavaFxObservable;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;

/**
 * @author Woo
 */
public class ConfirmPresenter extends ProjectBasePresenter {

    @FXML
    CheckBox confirmedCheckBox;

    @Override
    public void initialize() {
        confirmedCheckBox.requestFocus();
        JavaFxObservable.changesOf(confirmedCheckBox.selectedProperty())
                        .subscribe((cbx) -> {
                            SmartRouter.get().nextStepButton().setDisable(!cbx.getNewVal());
                        });
        SmartRouter.get().nextStepButton().setDisable(true);

        Platform.runLater(() -> {
            final Project project = SmartDataBus.get().replacement().getProject();
            renderProjectContent(project);
        });
    }

}
